package com.fourth.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fourth.dao.UBarticleDao;
import com.fourth.dao.UBbottomArticleDao;
import com.fourth.dao.UBbottomLinkDao;
import com.fourth.dao.UBhomeHeadNavDao;
import com.fourth.service.UBhomeHeadNavService;
import com.fourth.vo.QaiTaiSouSuo;
import com.ljx.entity.Article;
import com.ljx.entity.BottomArticle;
import com.ljx.entity.HeadNav;
import com.ljx.entity.Link;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2023/3/2 12:21
 * @Version 1.0
 */
@RestController
@RequestMapping("/system/home")
public class UBhomeHeadNavController {
	@Autowired
	private UBhomeHeadNavService uBhomeHeadNavService;
	@Autowired(required = false)
	private UBhomeHeadNavDao uBhomeHeadNavDao;

	/**
	 * 头部数据信息查询成功
	 * @return
	 */
	@GetMapping("/headNav/headNavigation")
	public Result headNavigation(){
		QueryWrapper<HeadNav> wrapper = new QueryWrapper<>();
//		wrapper.eq("head_id",1).or().eq("head_id",5).or().eq("head_id",6);
		wrapper.eq("is_disable",0);
		wrapper.eq("is_deleted",0);
		List<HeadNav> headNavs = uBhomeHeadNavDao.selectList(wrapper);
		return new Result(2000,"查询成功",headNavs);
	}

	@Autowired(required = false)
	private UBbottomArticleDao uBbottomArticleDao;

	/**
	 * 首页底部数据查询
	 */
	@RequestMapping("/bottomArticle/getQianAllBottomArticle")
	public Result getQianAllBottomArticle(){
		QueryWrapper<BottomArticle> wrapper = new QueryWrapper<>();
		wrapper.eq("is_disable",0);
		wrapper.eq("is_deleted",0);
		List<BottomArticle> bottomArticles = uBbottomArticleDao.selectList(wrapper);
		if(bottomArticles!=null){
			return new Result(2000,"查询成功",bottomArticles);
		}
		return new Result(5000,"查询成功",null);
	}

	/**
	 * 首页底部数据连接
	 */

	@Autowired(required = false)
	private UBbottomLinkDao uBbottomLinkDao;
	@RequestMapping("/link/getQianLink")
	public Result getQianLink(){
		QueryWrapper<Link> wrapper = new QueryWrapper<>();
		wrapper.eq("is_disable",0);
		List<Link> links = uBbottomLinkDao.selectList(wrapper);
		if(links!=null){
			return new Result(2000,"查询成功",links);
		}
		return new Result(5000,"查询成功",null);
	}



	/**
	 * 搜索店铺
	 * @param chandVal
	 * @param pageCurrent
	 * @param pageSize
	 * @return
	 */
	@RequestMapping("/zoneBusiness/findBusinessByName")
	public Result findBusinessByName(String chandVal, @RequestParam("pageCurrent")Integer pageCurrent,@RequestParam("pageSize") Integer pageSize){
		List<QaiTaiSouSuo> businessByName = uBhomeHeadNavDao.findBusinessByName(chandVal);
		return new Result(2000,"搜索成功",businessByName);
	}

	@Autowired(required = false)
	private UBarticleDao uBarticleDao;
	@RequestMapping("/article/getAllQianArticle/{id}")
	public Result getAllQianArticle(@PathVariable String id){
		Article article = uBarticleDao.selectArticleById(id);
		return new Result(2000,"查询文章成功",article);

	}

}
